<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.edu.service.*"%>
<%@ page import="com.edu.service.impl.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.edu.entity.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="x" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/student.css">
</head>
<script type="text/javascript" src="js/jquery-3.7.1.js"></script>
<body>
     <div id="myid1">
 		<p><img src="image/2.png"><span>学生管理系统</span></p><br>
		 <ul>

		      <li><img src="image/5.png"><a href="Teacstud.jsp" >学生管理</a></li><br><br><br>
		      <li><img src="image/6.png"><a href="Teadgrade.jsp">成绩管理</a></li><br><br><br>
		      <li><img src="image/8.png"><a href="log.jsp">退出登录</a></li><br><br><br>
		   </ul>
   
</div>
<div id="myWork">
   <div id="myStudent1">
             <p>
			             班级: <select name="mySel">
			                 <option>1年级1班</option>
			                 <option>1年级2班</option>
			                 <option>1年级3班</option>
			                 <option>1年级4班</option>
			           </select>&nbsp;&nbsp;
                 	姓名/电话: <input type="text" name="myName">
                 <input type="button" value="搜索" id="SouSuo" onclick="showAction('SouStudentServlet')">
				<input type="button" value="新增" id="myAdd" onclick="showAction('Saddjsp.jsp')">
				<input type="button" value="批量删除" onclick="showAction('DeleteAllServlet')">
				<input type="button" value="导入" id="myIn">
				<input type="button" value="导出" id="myOut">
            </p>
       </div>
        <table>
	        <tr>
	           <td><input type="checkbox" id="CheckBox" onclick="delAll()"></td>
	           <td>学生序号</td>
	           <td>姓名</td>
	           <td>班级</td>
	           <td>学号</td>
	           <td>性别</td>
	           <td>生日</td>
	           <td>联系电话</td>
	           <td>操作</td>
	        </tr>
	        <%
	        request.setCharacterEncoding("UTF-8");
	        Object obj=request.getAttribute("list");
	        if(obj==null){
	        	 UserService userservice=new UserServiceimpl();
	        	 List<Student> stu=userservice.sSelect();
	             request.setAttribute("list", stu);
	        }
        %>

		        <x:forEach items="${list }" var="stu" varStatus="status">
			        <x:choose>
				        <x:when test="${status.count%2==0 }">
				           <tr style="background-color:#ccc;">
					           <td><input type="checkbox"  name="check" value="${stu.sId }" ></td>
					           <td>${stu.sId }</td>
					           <td>${stu.ssName }</td>
					           <td>${stu.ssClass }</td>
					           <td>${stu.ssNum }</td>
					           <td>${stu.ssSex }</td>
					           <td>${stu.ssBir }</td>
					           <td>${stu.ssPhone }</td>
					           <td>
					           		 <a href="StudenUpdat.jsp?sId=${stu.sId }&ssName=${stu.ssName }&ssClass=${stu.ssClass }&ssNum=${stu.ssNum }&ssSex=${stu.ssSex }&ssBir=${stu.ssBir }&ssPhone=${stu.ssPhone }" id="myBj">编辑</a>
		                         	 <a href="StuDelServlet?sId=${stu.sId }" id="myDel">删除</a>
					           </td>
				        </tr>
				        </x:when>
				        <x:otherwise>
				            <tr>
				               <td><input type="checkbox"  name="check" value="${stu.sId }"></td>
				               <td>${stu.sId }</td>
				               <td>${stu.ssName }</td>
					           <td>${stu.ssClass }</td>
					           <td>${stu.ssNum }</td>
					           <td>${stu.ssSex }</td>
					           <td>${stu.ssBir }</td>
					           <td>${stu.ssPhone }</td>
				           <td>
				           		 <a href="StudenUpdat.jsp?sId=${stu.sId }&ssName=${stu.ssName }&ssClass=${stu.ssClass }&ssNum=${stu.ssNum }&ssSex=${stu.ssSex }&ssBir=${stu.ssBir }&ssPhone=${stu.ssPhone }" id="myBj">编辑</a>
		                         <a href="StuDelServlet?sId=${stu.sId }" id="myDel">删除</a>
				           </td>
				        </tr>
				        </x:otherwise>
			        </x:choose>
		          
	        </x:forEach>
    </table>
</div>
</body>
<script>
     function $(id){
    	 return document.getElementById(id);
     }
    function showAction(url){
    	$("form").action=url;
    	$("form").submit();
    }
    function delAll(){
    	var s=document.getElementsByName("check");
    	for(var i=0;i<s.length;i++){
    		s[i].checked=$("CheckBox").checked;
    	}
    }
    
</script>
</html>